<template>
  <s-modal
    title="新增"
    :visible="visible"
    width="800px"
    ok-text="保存"
    :confirm-loading="confirmLoading"
    :closable="!confirmLoading"
    @ok="save()"
    @cancel="()=>{if(!confirmLoading){ visible=false }}"
  >
    <div style="height:400px">
      <s-scroll>
        <s-form ref="form" :value="formValue">
          <s-form-item
            label="文件名称"
            size="middle"
            name="fileName"
            :colon="true"
            :display-title="true"
            :rules="[{'max':50,'message':'最长为50位'}]"
          >
            <s-input
              :allow-clear="true"
              placeholder="请输入文件名称"
              v-model="formValue.fileName"
              />
          </s-form-item>
          <s-form-item
            label="文件类型"
            size="middle"
            name="fileType"
            :colon="true"
            :display-title="true"
            :rules="[{'max':10,'message':'最长为10位'}]"
          >
            <s-input
              :allow-clear="true"
              placeholder="请输入文件类型"
              v-model="formValue.fileType"
              />
          </s-form-item>
          <s-form-item
            label="文件大小"
            size="middle"
            name="fileSize"
            :colon="true"
            :display-title="true"
            :rules="[{'max':30,'message':'最长为30位'}]"
          >
            <s-input
              :allow-clear="true"
              placeholder="请输入文件大小"
              v-model="formValue.fileSize"
              />
          </s-form-item>
          <s-form-item
            label="上传时间"
            size="middle"
            name="uploadTime"
            :colon="true"
            :display-title="true"
          >
            <s-input
              :allow-clear="true"
              placeholder="请输入上传时间"
              v-model="formValue.uploadTime"
              />
          </s-form-item>
          <s-form-item
            label="报表周期"
            size="middle"
            name="reportingCycle"
            :colon="true"
            :display-title="true"
            :rules="[{'max':4,'message':'最长为4位'}]"
          >
            <s-input
              :allow-clear="true"
              placeholder="请输入报表周期"
              v-model="formValue.reportingCycle"
              />
          </s-form-item>

        </s-form>
      </s-scroll>
    </div>
  </s-modal>
</template>

<script>

export default {
  name: 'Add',
  emits: ['change'],
  data() {
    return {
      formValue: {},
      confirmLoading: false,
      visible: false
    }
  },
  methods: {
    open() {
      this.formValue = {}
      this.visible = true
    },
    save() {
	  const _this=this
      const form = this.$refs.form
      form.validate((values,fullValue) => {
		
        this.confirmLoading = true
        this.$api.PUT('/modules/doorReportFile/insert', values).then(res => {
          this.confirmLoading = false
          this.visible = false
          this.$emit('success');
          this.$message.info(res.msg)
        }).catch(() => {
          this.confirmLoading = false
        })
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>